#include<stdio.h>
int main()
{
	int year = 0, mon = 0, day = 0;
	scanf_s("%d %d %d", &year, &mon, &day);
	int arr[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
	int arr1[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	if (year % 4 != 0)
	{
		int sum = 0;
		for (int i = 0; i < mon - 1; i++)
		{
			sum = arr[i] + sum;
		}
		printf("%d ", sum + day);
	}
	else
	{
		int sum = 0;
		for (int i = 0; i < mon - 1; i++)
		{
			sum = arr1[i] + sum;
		}
		printf("%d ", sum + day);
	}
	return 0;
}